import { createRouter, createWebHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'

const routes: RouteRecordRaw[] = [
  { path: '/', name: 'Home', component: () => import('@/views/Home.vue') },
  { path: '/products', name: 'ProductList', component: () => import('@/views/ProductList.vue') },
  { path: '/product/:id', name: 'ProductDetail', component: () => import('@/views/ProductDetail.vue') },
  { path: '/product/item/:id', name: 'ProductDetailItem', component: () => import('@/views/ProductDetail.vue') },
  { path: '/cart', name: 'Cart', component: () => import('@/views/Cart.vue') },
  { path: '/user', name: 'UserCenter', component: () => import('@/views/UserCenter.vue') },
  { path: '/address', name: 'Address', component: () => import('@/views/UserCenter.vue') },
  { path: '/login', name: 'Login', component: () => import('@/views/Login.vue') },
  { path: '/register', name: 'Register', component: () => import('@/views/Register.vue') },
  { path: '/order', name: 'Order', component: () => import('@/views/Order.vue') },
  { path: '/myorders', name: 'MyOrders', component: () => import('@/views/MyOrders.vue') },
  { path: '/pay', name: 'Pay', component: () => import('@/views/Pay.vue') },


  {
    path: '/admin',
    component: () => import('@/views/admin/Home.vue'),
    children: [
      { path: '', redirect: '/admin/banner' },
      { path: 'banner', component: () => import('@/views/admin/Banner.vue') },
      { path: 'product', component: () => import('@/views/admin/Product.vue') },
      { path: 'category', component: () => import('@/views/admin/Category.vue') },
      { path: 'help1', component: () => import('@/views/admin/Help.vue') },
    ]
  },
  { path: '/help', name: 'Help', component: () => import('@/views/help.vue') },
]

const router = createRouter({
  history: createWebHistory(),//HTML5 History 模式的路由。
  routes,
})

export default router
